home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2002 November / SGI IRIX 6.5 Applications 2002 November.iso / dist / gateway.idb / usr / OnRamp / lib / java.pm.z / java.pm
Encoding:
Text File  |  2002-06-12  |  11.9 KB  |  476 lines

  1. #!/usr/bin/perl5
  2.  
  3.  
  4. #------------------------------------------------------------
  5. $js_check_int =
  6. "function checkInt(check, base) {
  7.     if (base == 10) word = \"0123456789\";
  8.     else if (base == 16) word = \"0123456789abcdefABCDEF\";
  9.     else return (false);
  10.  
  11.     for (i=0; i<check.length; i++)
  12.         if (word.indexOf(check.charAt(i)) == -1) return (false);
  13.     return (true);
  14. }
  15. function checkInt_c(check, base) {
  16.     if (base == 10) word = \"0123456789\";
  17.     else if (base == 16) word = \"0123456789abcdefABCDEF\";
  18.     else return (false);
  19.  
  20.     if (word.indexOf(check) == -1) return (false);
  21.     return (true);
  22. }";
  23.  
  24.  
  25. #------------------------------------------------------------
  26. $js_account_main =
  27. "which = \"none\";
  28. function runSubmit() {
  29.     if(which == \"add\") return runAdd();
  30.     if(which == \"edit\") return runEdit();
  31.     if(which == \"delete\") return runDelete();
  32.     return (true);
  33. }
  34. function markAdd() { help = 0; which = \"add\"; }
  35. function markEdit() { help = 0; which = \"edit\"; }
  36. function markDelete() { help = 0; which = \"delete\"; }
  37. function markOther() { help = 0; which = \"none\"; }
  38. function runAdd()  {
  39.     form = document.AccountForm
  40.     if (!testAdd(form)) return (false);
  41.     return (true);
  42. }
  43. function runEdit()  {
  44.     Ctrl = document.AccountForm.chosen
  45.     none = true;
  46.     for(j = 0; j < Ctrl.length; j++) {
  47.         if (Ctrl.options[j].selected) { none = false; break; }
  48.     }
  49.     if (none) {
  50.         errorBox (Ctrl, \"To edit an existing \" + type + \", \"
  51.             + \"first select an \" + type + \"\\nfrom the list, \"
  52.             + \"then click the edit button.\");
  53.         return (false);
  54.     }    
  55.     return (true);
  56. }
  57. function runDelete() {
  58.     Ctrl = document.AccountForm.chosen;
  59.     none = true;
  60.     for(j = 0; j < Ctrl.length; j++) {
  61.         if (Ctrl.options[j].selected) { none = false; break; }
  62.     }
  63.     if (none) {
  64.         errorBox (Ctrl, \"To delete an existing \" + type + \", first \"
  65.             + \"select an \" + type + \"\\nfrom the list, then click \"
  66.             + \"the delete button.\");
  67.         return (false);
  68.     }
  69.     return (true);
  70. }";
  71.  
  72. #------------------------------------------------------------
  73. $js_account_add =
  74. "which = \"none\";
  75. function runSubmit() {
  76.     if(which == \"add\") return runAdd();
  77.     return (true);
  78. }
  79. function markAdd() { help = 0; which = \"add\"; }
  80. function markOther() { help = 0; which = \"none\"; }
  81. function runAdd()  {
  82.     form = document.AddForm;
  83.     if (!testAdd(form)) return (false);
  84.     return (true);
  85. }";
  86.  
  87.  
  88. #------------------------------------------------------------
  89. $js_account_edit =
  90. "which = \"none\";
  91. function runSubmit() {
  92.     if(which == \"edit\") return runEdit();
  93.     return (true);
  94. }
  95. function markEdit() { help = 0; which = \"edit\"; }
  96. function markOther() { help = 0; which = \"none\"; }
  97. function runEdit()  {
  98.     form = document.EditForm;
  99.     if (!testEdit(form)) return (false);
  100.     return (true);
  101. }";
  102.  
  103.  
  104. #------------------------------------------------------------
  105. $js_standard =
  106. "which = \"none\";
  107. function runSubmit() {
  108.     if (help) return (false);
  109.     if(which == \"ok\") return runOK();
  110.     return (true);
  111. }
  112. function markOK() { help = 0; which = \"ok\"; }
  113. function markOther() { help = 0; which = \"none\"; }
  114. function runOK() {
  115.     form = document.StandardForm;
  116.     if (!checkForm(form)) return (false);
  117.     return (true);
  118. }";
  119.  
  120.  
  121. #------------------------------------------------------------
  122. $js_help =
  123. "function do_help(file) {
  124.     help = 1;
  125.     helpWindow=window.open(file, \"GATEWAY_HELP\",
  126.         \"toolbar=no,scrollbars=yes,width=500,height=500\");
  127.     return (false);
  128. }";
  129.  
  130.  
  131. #------------------------------------------------------------
  132. $js_error_box =
  133. "function errorBox (Ctrl, ErrorMessage) {
  134.     alert (ErrorMessage);  Ctrl.focus();  return;
  135. }";
  136.  
  137.  
  138. #------------------------------------------------------------
  139. $js_phone =
  140. "$js_check_int
  141. function testPhone(Ctrl) {
  142.     if (Ctrl.value == \"\") {
  143.         errorBox (Ctrl, \"The phone number is required.\");
  144.         return (false);
  145.     }
  146.     error = testPhoneChars(Ctrl.value);
  147.     if (error == 1) {
  148.         errorBox (Ctrl, \"The phone number cannot contain spaces.\");
  149.         return (false);
  150.     }
  151.     if (error == 2) {
  152.         errorBox (Ctrl, \"The phone number cannot contain \"
  153.             + \"\\nletters or punctuation.\");
  154.         return (false);
  155.     }
  156.     return (true);
  157. }
  158. function testPhoneChars(word) {
  159.     for(i = 0; i < word.length; i++) {
  160.         c = word.charAt(i);
  161.         if (c == ' ') return 1;
  162.         if (c != \'(\' && c != \')\' && c != \'-\' && c != \',\') {
  163.             if (! checkInt_c(c, 10)) return 2;
  164. //            num = parseInt(c);
  165. //            if(isNaN(num)) return 2;
  166.         }
  167.     }
  168.     return 0;
  169. }";
  170.  
  171.  
  172. #------------------------------------------------------------
  173. $js_meta =
  174. "function testMeta(Ctrl, what) {
  175.     if (Ctrl.value == \"\") { 
  176.         errorBox (Ctrl, \"The \" + what + \" is required.\");
  177.         return (false);
  178.     }
  179.     error = testMetaChars(Ctrl.value);
  180.     if (error == 1) {
  181.         errorBox (Ctrl, \"The \" + what + \" cannot be more \"
  182.             + \"\\nthan 8 characters long.\");
  183.         return (false);
  184.     }
  185.     if (error == 2) {
  186.         errorBox (Ctrl, \"The \" + what + \" cannot contain \"
  187.             + \"the \" + illegal + \" character.\");
  188.         return (false);
  189.     }
  190.     if (error == 3) {
  191.         errorBox (Ctrl, \"The \" + what + \" cannot contain \"
  192.             + \"spaces.\");
  193.         return (false);
  194.     }
  195.     return (true);
  196. }
  197. function testMetaChars(word) {
  198.     if (word.length > 8) return 1;
  199.     loginChars = \"{}()*!~<>?|[]'&^\$\@\#`\\\";:\\\\/+=,%\";
  200.     for(j = 0; j < loginChars.length; j++) {
  201.         c = loginChars.charAt(j);
  202.         if (word.indexOf(c, 0) != -1) { illegal = c; return 2; }
  203.     }
  204.     for (c = 0; c < word.length; c++) {
  205.         if (word.charAt(c) == ' ') return 3;
  206.     }
  207.     return 0;
  208. }";
  209.  
  210.  
  211. #------------------------------------------------------------
  212. $js_iplist =
  213. "function testIPList(Ctrl, what) {
  214.     my_count = 0;
  215.     whitespace = \" \\n\\r\\t\\f\";  space = true;
  216.     for(start=0, cur=0; cur < Ctrl.value.length; cur++) {
  217.         for(i = 0; i < whitespace.length; i++) {
  218.             c = whitespace.charAt(i);
  219.             if (Ctrl.value.charAt(cur) == c) { // found whitespace
  220.                 if (space == false) { 
  221.                     space = true;  
  222.                     if(cur != start) { 
  223.                         host = Ctrl.value.substring(start,cur); 
  224. //                        if (flag == 1) host = host.indexOf(':',0);
  225.                         my_count++; 
  226.                         if (!testIPaddress(host,false)) { 
  227.                             errorBox (Ctrl, \"Invalid \" + what + \": \" + host); 
  228.                             return (false); 
  229.                         } 
  230.                     } 
  231.                 }
  232.                 break;
  233.             } else {                           // found character
  234.                 if (space == true) { 
  235.                     space = false;  
  236.                     start = cur; 
  237.                 }
  238.             }
  239.         }
  240.     }
  241.     if(cur != start && space == false) { 
  242.         host = Ctrl.value.substring(start,cur); 
  243. //        if (flag == 1) host = host.indexOf(':',0);
  244.         my_count++; 
  245.         if (!testIPaddress(host,false)) { 
  246.             errorBox (Ctrl, \"Invalid \" + what + \": \" + host
  247.                 + \"\\nin \" + what + \" list.\"); 
  248.             return (false); 
  249.         } 
  250.     }
  251.     return (true);
  252. }";
  253.  
  254.  
  255. #------------------------------------------------------------
  256. $js_ip = 
  257. "$js_check_int;
  258. function testIPaddress(address, netmask) {
  259.     start = 0;
  260.     while ((address.charAt(start) == ' ') || (address.charAt(start) == '\t')) {
  261.         start++;
  262.     }
  263.  
  264.     end = address.length - 1;
  265.     while ((end > 0) && ((address.charAt(end) == ' ') || (address.charAt(end) == '\t'))) {
  266.         end--;
  267.     }
  268.  
  269.     if ((start > 0) && (end == 0)) {
  270.         return (false);
  271.     }
  272.     
  273.     if (address.substring(start, start + 2) == \"0x\")  {
  274. if (! checkInt(address.substring(start + 2, end), 16)) return (false);
  275. //        if (isNaN(parseInt(address.substring(start + 2, end), 16))) {
  276. //            return (false);
  277. //        }
  278.         if (netmask) {
  279.             for (state = 0, start += 2; start <= end; start++) {
  280.                 value = address.charAt(start);
  281.                 if (value == 'f') {
  282.                     if (state != 0) {
  283.                         return (false);
  284.                     }
  285.                 } else if ((value == 'c') || (value == 'e')) {
  286.                     if (state != 0) {
  287.                         return (false);
  288.                     }
  289.                     state = 1;
  290.                 } else if (value == '0') {
  291.                     state = 1;
  292.                 } else {
  293.                     return (false);
  294.                 }
  295.             }
  296.         }
  297.         return (true);
  298.     }
  299.  
  300.     for (state = 0, count = 0; start <= end; count++) {
  301.         dot = address.indexOf('.', start);
  302.         if (dot < 0) {
  303.             dot = end + 1;
  304.         } else if (dot == 0 || dot == end) {
  305.             return (false);
  306.         }
  307. //        if (isNaN(parseInt(address.substring(start, dot), 10))) {
  308.         if (! checkInt(address.substring(start, dot), 10)) {
  309.             return (false);
  310.         }
  311.         value = parseInt(address.substring(start, dot), 10);
  312.         if (netmask) {
  313.             if (value == 255) {
  314.                 if (state != 0) {
  315.                     return (false);
  316.                 }
  317.             } else if ((value == 254) || (value == 252) ||
  318.                 (value == 248) || (value == 240) || (value == 224) ||
  319.                 (value == 192) || (value == 128)) {
  320.                 if (state != 0) {
  321.                     return (false);
  322.                 }
  323.                 state = 1;
  324.             } else if (value == 0) {
  325.                 state = 1;
  326.             } else {
  327.                 return (false);
  328.             }
  329.         }
  330.         if ((value > 255) || (value < 0)) {
  331.             return (false);
  332.         }
  333.         start = dot + 1;
  334.     }
  335.     if (count > 4) {
  336.         return (false);
  337.     }
  338.     return (true);
  339. }";
  340.  
  341.  
  342. #------------------------------------------------------------
  343. $js_hostlist =
  344. "function testHostlist(Ctrl, what) {
  345.     whitespace = \" \\n\\r\\t\\f\";  space = true;
  346.     for(start=0, cur=0; cur < Ctrl.value.length; cur++) {
  347.         for(i = 0; i < whitespace.length; i++) {
  348.             c = whitespace.charAt(i);
  349.             if (Ctrl.value.charAt(cur) == c) { // found whitespace
  350.                 if (space == false) { 
  351.                     space = true;  
  352.                     if(cur != start) { 
  353.                         host = Ctrl.value.substring(start,cur); 
  354.                         if (!testHostname(Ctrl, host, what, 0)) return (false); 
  355.                     } 
  356.                 } 
  357.                 break;
  358.             } else {                           // found character
  359.                 if (space == true) { 
  360.                     space = false;  
  361.                     start = cur; 
  362.                 }
  363.             }
  364.         }
  365.     }
  366.     if(cur != start && space == false) { 
  367.         host = Ctrl.value.substring(start,cur); 
  368.         if (!testHostname(Ctrl, host, what, 0)) return (false); 
  369.     }
  370.     return (true);
  371. }";
  372.  
  373.  
  374. #------------------------------------------------------------
  375. $js_hostname =
  376. "$js_check_int;
  377. function testHostname(Ctrl, host, what, flag) {
  378.     if (host == \"\") { 
  379.         if (flag == 1) return (true);
  380.         errorBox (Ctrl, \"The \" + what + \" is required.\"); 
  381.         return (false); 
  382.     }
  383.     error = testHost(host);
  384.     if (error == 1) { 
  385.         errorBox (Ctrl, \"The \" + what + \" cannot \\ncontain \" 
  386.             + illegal + \" characters.\"); 
  387.         return (false); 
  388.     }
  389.     if (error == 2) { 
  390.         errorBox (Ctrl, \"The \" + what + \" cannot start or \\n \"
  391.             + \"end with a . or - or _ character.\"); 
  392.         return (false); 
  393.     }
  394.     if (error == 3) { 
  395.         errorBox (Ctrl, \"The \" + what + \" cannot contain \\n\"
  396.             + \"consecutive . or - or _ characters.\"); 
  397.         return (false); 
  398.     }
  399.     if (error == 4) { 
  400.         errorBox (Ctrl, \"The \" + what + \" cannot contain spaces.\"); 
  401.         return (false); 
  402.     }
  403.     if (error == 5) { 
  404.         errorBox (Ctrl, \"The \" + what + \" cannot begin \\nwith \"
  405.             + \"a number.\"); 
  406.         return (false); 
  407.     }
  408.     return (true);
  409. }
  410. function testHost(word) {
  411.     metaChars = \"{}()*!~<>?|[]'&^\$\@\#`\\\";:\\\\/+=,%\";
  412.     start = 0;  
  413.     while (word.charAt(start) == ' ') { start++; }
  414.     end = word.length-1; 
  415.     while (word.charAt(end) == ' ') { end--; }
  416.     for(j = 0; j < metaChars.length; j++) {
  417.         c = metaChars.charAt(j); 
  418.         i = word.indexOf(c, 0); 
  419.         if (i != -1) { illegal = c; return 1; }
  420.     }
  421.     sch = word.charAt(start); ech = word.charAt(end);
  422.     if(sch == '.' || sch == '-' || sch == '_') return 2;
  423.     if(ech == '.' || ech == '-' || ech == '_') return 2;
  424.     for(j = start; j <= end; j++) { 
  425.         ch = word.charAt(j); 
  426.         if (ch == '.' || ch == '-' || ch == '_') { 
  427.             if (word.charAt(j+1) == ch) return 3; 
  428.         } if (ch == ' ') { return 4; } 
  429.     }
  430.     if (checkInt(sch, 10)) return 5;
  431. //    if(!isNaN(parseInt(sch))) return 5;
  432.     return 0;
  433. }";
  434.  
  435.  
  436. #------------------------------------------------------------
  437. $js_filename =
  438. "function testFilename(Ctrl, what) {
  439.     word = Ctrl.value;
  440.     if (word == \"\") {
  441.         errorBox (Ctrl, \"The \" + what + \" is required.\");
  442.         return (false);
  443.     }
  444.     if (!testFileChars(word)) {
  445.         errorBox (Ctrl, \"The \" + what + \" cannot \\ncontain \"
  446.             + illegal + \" characters.\");
  447.         return (false);
  448.     }
  449.     for(i = 0; i < word.length; i++) {
  450.         if (word.charAt(i) == ' ') {
  451.             errorBox (Ctrl, \"The \" + what + \" cannot \\ncontain spaces.\");
  452.             return (false);
  453.         }
  454.     }
  455.     if (word.charAt(0) != '/') {
  456.         errorBox (Ctrl, \"The \" + what + \" must be fully qualified.\");
  457.         return (false);
  458.     }
  459.     return (true);
  460. }
  461. function testFileChars(word) {
  462.     metaChars = \"{}()*!~<>?|[]'&^\$\@\#`\\\";:\";
  463.     for(j = 0; j < metaChars.length; j++) {
  464.         illegal = metaChars.charAt(j);
  465.         if (word.indexOf (illegal, 0) != -1) return (false);
  466.     } return (true);
  467. }";
  468.  
  469.  
  470. #------------------------------------------------------------
  471. $js_empty_passwd_check =
  472. "function bad_password() {
  473.     return(true);
  474. }";
  475.  
  476.